<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

// autor/i etapy: Martin Štefaňák
// 9.12.2013

class Rozvrh extends CI_Controller {

	public function index() {
		$this->table();
	}
	
	public function zoznam($zameranie = null, $ucitel = null) {
	if($zameranie === 'null') {
		$zameranie = null;
	}	
	$this->load->model('model_rozvrh');
	$data['dump'] = $this->model_rozvrh->get_vypis_list($zameranie,$ucitel);
    if ($this->session->userdata('is_logged_in')){
		    if ($this->session->userdata('admin'))
		        $this->template->make_template($data, 'admin_rozvrh');
        else
            $this->template->make_template($data, 'user_rozvrh');
    }else
        $this->template->make_template($data, 'rozvrh');
	//	$this->template->make_template('', 'rozvrh');
	}
	public function table() {
		$this->load->model('model_rozvrh');
		$data['dump'] =  $this->model_rozvrh->get_table();
    if ($this->session->userdata('is_logged_in')){
        if ($this->session->userdata('admin'))
		        $this->template->make_template($data, 'admin_rozvrh');
        else
            $this->template->make_template($data, 'user_rozvrh'); 
    }else
        $this->template->make_template($data, 'rozvrh');
	}
	
	public function myzoznam() {
		 if ($this->session->userdata('is_logged_in')){
		    if (!$this->session->userdata('admin')) {
				$this->load->model('model_rozvrh');
				$data['dump'] =  $this->model_rozvrh->get_vypis_mojlist($this->session->userdata('id'));
				$this->template->make_template($data, 'user_myrozvrh'); 
			} else {
				redirect('main');
			}
		} else {
			redirect('main/restricted');
		}
	}
  
  //volanie pre MOJ rozvrh
  public function user_rozvrh() {
   	 if ($this->session->userdata('is_logged_in')){
		$this->load->model('model_rozvrh');
		$data['dump']= $this->model_rozvrh->moj_rozvrh($this->session->userdata('id'));
		if ($this->session->userdata('admin')) {
			redirect('rozvrh');
		} else {
			$this->template->make_template($data, 'user_myrozvrh'); 
		}
	 } else {
		redirect('main/restricted');
	 }
      
  }
  
		
}
	
?>